package com.zc.security.utils;

import java.io.Serializable;

@SuppressWarnings("serial")
public class ResponseData<T> implements Serializable {

    private Integer code;

    private String msg;

    private Long count;

    private T data;

    public ResponseData() {
    }

    public ResponseData(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseData(Integer code, String msg, T data, Long count) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public static ResponseData ok() {
        return new ResponseData(200, "success", null, null);
    }

    public static ResponseData ok(String msg) {
        return new ResponseData(200, msg, null, null);
    }

    public static <T> ResponseData ok(T data) {
        return new ResponseData(200, "success", data, null);
    }

    public static ResponseData ok(Integer code, String msg) {

        return new ResponseData(code, msg, null, null);
    }

    public static ResponseData ok(Object data, Long count) {

        return new ResponseData(200, "success", data, count);
    }

    public static ResponseData ok(String msg, Object data) {

        return new ResponseData(200, msg, data, null);
    }

    public static <T> ResponseData ok(Integer code, String msg, T data) {

        return new ResponseData(code, msg, data, null);
    }

    public static <T> ResponseData ok(Integer code, String msg, T data, Long count) {

        return new ResponseData(code, msg, data, count);
    }

    public static ResponseData fail(String msg) {

        return new ResponseData(400, msg);
    }

    public static ResponseData fail(Integer code, String msg) {

        return new ResponseData(code, msg);
    }

    public static <T> ResponseData fail(Integer code, String msg, T data) {

        return new ResponseData(code, msg, data, null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
